package com.dmx.cep.action.contentManage;

import java.util.Date;
import java.util.List;

import com.dmx.cep.service.ContentService;
import com.dmx.fw.web.struts2.action.CommonQueryAction;

/**
 * 
 * @author magicyang
 *	元数据管理查询Action
 */
public class MetadataSearchAction extends CommonQueryAction{
	
	private String q_title;
	
	private String q_actor;
	
	private String q_director;
	
	private Integer q_status;
	
	private Date q_releaseDate;
	
	private String q_contID;
	
	private Integer q_captionSts;
	
	private Integer q_manageStatus;
	
	private String q_genre;
	
	private List<Object[]> contentTypeList;
	
	private ContentService contentService;
	
	public String execute() throws Exception{
		
        if(this.act.equals("importTaskSearch")){
        	return importTaskSearch();
        }
        
        this.busiId="searchMetadata";
        
		if(this.sortField==null||"".equals(this.sortField.trim())){
			this.sortField="CREATION_DATE";
		}
        
		String result=super.execute();
		
		List searchResult=this.pageInfo.getSearchResult();
		
		for(int i=0;searchResult!=null&&i<searchResult.size();i++){
			List obj=(List)searchResult.get(i);
			String genre=obj.get(2).toString();
			if(genre!=null){
				String genreText="";
				String[] genreArr=genre.split(",");
				for(String str:genreArr){
					genreText+=this.getText(str)+",";
				}
				if(genreText.endsWith(",")) genreText=genreText.substring(0,genreText.length()-1);
				
				obj.set(2, genreText);
			}
		}
		
		contentTypeList=contentService.getContentTypeList();
		
		return result;
	}
	
	
	public String importTaskSearch() throws Exception{
		this.busiId="searchAdiImportTask";
		
		super.doQuery();
		
		return "taskList";
	}
	
	

	public String getQ_title() {
		return q_title;
	}

	public void setQ_title(String q_title) {
		this.q_title = q_title;
	}

	public String getQ_actor() {
		return q_actor;
	}

	public void setQ_actor(String q_actor) {
		this.q_actor = q_actor;
	}

	public String getQ_director() {
		return q_director;
	}

	public void setQ_director(String q_director) {
		this.q_director = q_director;
	}

	public Integer getQ_status() {
		return q_status;
	}

	public void setQ_status(Integer q_status) {
		this.q_status = q_status;
	}

	public Date getQ_releaseDate() {
		return q_releaseDate;
	}

	public void setQ_releaseDate(Date date) {
		q_releaseDate = date;
	}

	public String getQ_contID() {
		return q_contID;
	}

	public void setQ_contID(String q_contid) {
		q_contID = q_contid;
	}

	public Integer getQ_captionSts() {
		return q_captionSts;
	}

	public void setQ_captionSts(Integer sts) {
		q_captionSts = sts;
	}


	public Integer getQ_manageStatus() {
		return q_manageStatus;
	}


	public void setQ_manageStatus(Integer status) {
		q_manageStatus = status;
	}


	public List<Object[]> getContentTypeList() {
		return contentTypeList;
	}


	public void setContentTypeList(List<Object[]> contentTypeList) {
		this.contentTypeList = contentTypeList;
	}


	public ContentService getContentService() {
		return contentService;
	}


	public void setContentService(ContentService contentService) {
		this.contentService = contentService;
	}


	public String getQ_genre() {
		return q_genre;
	}


	public void setQ_genre(String q_genre) {
		this.q_genre = q_genre;
	}
}
